/*
 * @Author: NtyAaron
 * @Date: 2021-04-13 10:39:00
 * @LastEditors: NtyAaron
 * @LastEditTime: 2021-06-23 14:21:23
 * @Description: 文章使用
 * @FilePath: \dwq\api\article\article.js
 */

import request from '../../utils/request'

// 获取城市列表/不分页
export const getCityList = (e) => {
  let res = request({
    url: `/city/getCityList?language=${e || 1}`,
  })

  return res
}

// 获取父级行业列表/不分页
export const getParentIndustryList = (e) => {
  return request({
    url: `/city/getParentIndustryList?language=${e || 1}`,
  })
}

// 获取子行业列表/不分页
export const getIndustryList = (e) => {
  return request({
    url: `/city/getIndustryList?language=${e.language || 1}&parentId=${e.industryId}`,
  })
}

// 获取所有行业
export const getAllIndustry = (e) => {
  return request({
    url: `/city/getAllIndustry?language=${e || 1}`,
  })
}

// 获取文章分类列表/不分页
export const getCategoryList = (e) => {
  return request({
    url: `/category/getCategoryList?language=${e.language || 1}&type=${e.type}`,
  })
}

// 获取子分类列表/不分页(分类类型是商务支援和活动及培训5/6的时候才有子分类)
export const getChildList = (data) => {
  return request({
    url: `/category/getChildList`,
    data,
  })
}

// 获取文章列表(不分页)
export const getArticleList = (data) => {
  data.industryId = data.industryId == 0 ? '' : data.industryId
  return request({
    url: `/article/getArticleList`,
    data,
  })
}
// 获取文章列表(分页)
export const getArticlePage = (data) => {
  // data.industryId = data.industryId == 0 ? 0 : data.industryId
  // data.categoryId = data.categoryId == 0 ? 0 : data.categoryId
  return request({
    url: `/article/getArticlePage`,
    data,
  })
}

// 获取文章详情
export const getArticle = (data) => {
  return request({
    url: `/article/getArticle`,
    data,
  })
}

// 收藏文章
export const saveCollect = (data) => {
  return request({
    url: `/collect/saveCollect`,
    method: 'post',
    data,
  })
}
// 取消收藏
export const delCollect = (data) => {
  return request({
    url: `/collect/delCollect`,
    data,
  })
}

// 获取收藏列表
export const getCollectList = (data) => {
  return request({
    url: `/collect/getCollectList`,
    data,
  })
}
